package com.example.user;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.user.view.UserAboutPageFragment;
import com.example.user.view.MyGamePageFragment;
import com.example.user.view.UserIssuePageFragment;

import java.util.ArrayList;
import java.util.List;

public class UserPageCollectionAdapter extends FragmentStateAdapter {

    private List<Fragment> mFragments;
    private List<Integer> fragmentsNames;

    public UserPageCollectionAdapter(@NonNull Fragment fragment) {
        super(fragment);
        init();
    }

    private void init(){
        mFragments=new ArrayList<>();
        fragmentsNames=new ArrayList<>();
        mFragments.add(new MyGamePageFragment());
        fragmentsNames.add(R.string.user_my_game);
        mFragments.add(new UserIssuePageFragment());
        fragmentsNames.add(R.string.user_issue_page);
        mFragments.add(new UserAboutPageFragment());
        fragmentsNames.add(R.string.user_about_page);
    }

    @Override
    public Fragment createFragment(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getItemCount() {
        return mFragments.size();
    }

    public Integer getFragmentName(int position) {
        return fragmentsNames.get(position);
    }
}
